package com.che168.barchartdemo.widget.BarChart;

import android.content.Context;
import android.graphics.Canvas;
import android.util.AttributeSet;

import com.che168.barchartdemo.R;

import java.util.List;

/**
 * 柱形图
 * @author zhudeshuai
 * @since 16/7/1
 */
public class BarChartView extends GraphicalView {

    private BarChar mBarChar = new BarChar(0, 2000, 5);

    /**
     * 是否使用动画
     */
    private boolean userAnimation = true;

    public BarChartView(Context context) {
        this(context, null);
    }

    public BarChartView(Context context, AttributeSet attrs) {
        super(context, attrs);
        mBarChar.setBarColor(context.getResources().getColor(R.color.barCharColor));
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
        mBarChar.setRectFBg(0, 0, getMeasuredWidth(), getMeasuredHeight());
    }



    public void setShowData(List<BarChartData> data) {
        mBarChar.setShowData(data);
        refreshChart();
    }



    @Override
    public void render(Canvas canvas) {
        mBarChar.render(canvas);
    }
}
